<?php

namespace app\admin\model;

use app\admin\common\Constants;
use think\Model;

/**
 * 审批类型
 */
class Approval extends Common
{

    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = false;

    public function approvers()
    {
        return $this->hasMany('Approver', 'app_id', 'id');
    }

    public function seal()
    {
        return $this->belongsTo('Seal', 'seal_id', 'id');
    }

    public function getStatusTxtAttr($value, $data)
    {
        $status = Constants::getApprovalStatuses();
        return $status[$data['status']];
    }

    public function getIsFreeTxtAttr($value, $data)
    {
        $type = Constants::getApprovalStyleFreees();
        return $type[$data['is_free']];
    }

}